package no.cicero.testframework.common.xml;

import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;

public class XmlImporterDelegateBase implements IXmlImporterDelegate{
    
    public void handleStartElement(XmlImporter importer, XmlTag tag) throws SAXException {
    }

    public void handleEndElement(XmlImporter importer, XmlTag tag) throws SAXException {
    }

    public void handleText(XmlImporter importer, XmlTag tag, String text) throws SAXException {
    }

    public void handleWarning(XmlImporter importer, XmlTag tag, SAXParseException ex) throws SAXException {
    }

    public void handleError(XmlImporter importer, XmlTag tag, SAXParseException ex) throws SAXException {
        throw ex;
    }

    public void handleFatalError(XmlImporter importer, XmlTag tag, SAXParseException ex) throws SAXException {
        throw ex;
    }

    protected boolean getBooleanAttribute( final XmlAttributes atts, final String name,
            final boolean defaultValue ) {

        boolean value = defaultValue;

        if( atts.getValue( name ) != null ) {
            String valueStr = atts.getValue( name );
            if( valueStr.equalsIgnoreCase( "true" ) ) {
                value = true;
            }
        }

        return value;
    }
}
